package com.xuxin.baby.activity;

import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.xuxin.baby.R;
import com.xuxin.baby.base.BaseActivity;
import com.xuxin.baby.base.BaseConstant;
import com.xuxin.baby.utils.ACache;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by xu_xin
 * Created on 2020.08.12 0012
 * 身高体重头围图表
 */
public class ChildDataChartActivity extends BaseActivity {
    @BindView(R.id.title_left)
    ImageView title_left;
    @BindView(R.id.title_right)
    ImageView title_right;
    @BindView(R.id.title_name)
    TextView title_name;
    @BindView(R.id.web)
    WebView web;

    @Override
    public void setContentView() {
        setContentView(R.layout.view_web);
    }

    @Override
    public void initView() {
        title_name.setText("身高体重头围曲线图");
    }

    @Override
    public void initData() {
        ACache aCache = ACache.get(this);
        String childId = aCache.getAsString(BaseConstant.childId);
        initWebView(web);
        web.loadUrl("http://129.204.116.243:8002/#/" + childId);
    }

    @Override
    public void onComplete() {

    }

    @Override
    @OnClick({R.id.title_left})
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.title_left) {
            finish();
        }
    }

    private void initWebView(WebView webView) {
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setDisplayZoomControls(true);
    }
}